package leetcode;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * ClassName: Main
 * Package: leetcode
 * Description:
 *
 * @Author wjn
 * @Create 2025/8/23 10:15
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int  n = Integer.parseInt(st.nextToken());
        long m = Long.parseLong(st.nextToken());

        long total = 0;
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(br.readLine());
            long x = Long.parseLong(st.nextToken());
            long y = Long.parseLong(st.nextToken());

            long min = Math.min(x, y);
            long max = Math.max(x, y);

            if (max <= m) {
                total += min;
            } else {
                total += max;
            }
        }
        System.out.println(total);
    }
}
